package com.gxa.controller;

import com.gxa.pojo.Complete;
import com.gxa.service.CompleteService;
import com.gxa.util.JsonResult;
import com.sun.org.apache.bcel.internal.generic.IF_ACMPEQ;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;
@Controller
@CrossOrigin
@RequestMapping("/complete")
public class CompleteController {
    @Resource
    private CompleteService completeService=null;

     @PostMapping("/find")
    @ResponseBody
    public Map find(Integer id){
        JsonResult jsonResult = new JsonResult();
        if(id!=null||!id.equals("")){
            Complete byId = completeService.findById(id);
            jsonResult.setCode("200");
            jsonResult.setData(byId);
            return   jsonResult.getValues();
        }
        jsonResult.setCode("202");
        jsonResult.setMsg("id不能为空");
        return jsonResult.getValues();
    }

    @PostMapping("/insert")
    @ResponseBody
    public Map insert(@RequestBody Complete complete){
        JsonResult jsonResult = new JsonResult();
        Boolean byId = completeService.insetById(complete);
        if(byId!=false){
            jsonResult.setCode("200");
            jsonResult.setMsg("添加成功");
            return jsonResult.getValues();
        }
        jsonResult.setCode("201");
        jsonResult.setMsg("添加失败");
        return jsonResult.getValues();
    }

}
